package cn.org.timespace.plat.action.mc;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.org.timespace.easyframe.action.EFBaseAction;
import cn.org.timespace.ons.util.pager.Pager;
import cn.org.timespace.ons.util.pager.PagerHelper;

import cn.org.timespace.plat.service.mc.PlatMcInfoService;
import cn.org.timespace.plat.vo.mc.PlatMcInfo;

public class McInfoAction  extends EFBaseAction{
	private static Log log = LogFactory.getLog(McInfoAction.class);
	private PlatMcInfoService platMcInfoService;

	public PlatMcInfoService getPlatMcInfoService() {
		return platMcInfoService;
	}

	public void setPlatMcInfoService(PlatMcInfoService platMcInfoService) {
		this.platMcInfoService = platMcInfoService;
	}
	
	public McInfoAction(){
		super(new PlatMcInfoModel());
	}
	
	PlatMcInfoModel platMcInfoModel = (PlatMcInfoModel)this.getModel();
	
	
	/**
	 * 显示信息终端列表
	 * @return
	 * @throws Exception
	 */
	public String doList() throws Exception{
		Pager p = PagerHelper.getPagerInstance(getRequest());
		List<Object> resList = platMcInfoService.findByCondition(platMcInfoModel,p);
		
		if(resList != null && resList.size() == 2){
			p.setTotalCount(((Integer)resList.get(0)));
			p.setData((List)resList.get(1));
		}
		return LIST;
	}
	
	/**
	 * 查看信息终端内容
	 * @return
	 * @throws Exception
	 */
	public String doView() throws Exception{
		String theId = getRequest().getParameter("theId");
		Pager p = PagerHelper.getPagerInstance(getRequest());
		PlatMcInfo platMcInfo = platMcInfoService.findById(theId);
		platMcInfoModel.setPlatMcInfo(platMcInfo);
		return VIEW;
	}
}